package com.braveo.dict;

import java.util.List;

import android.app.ListActivity;
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class DatabaseChooseView extends ListActivity {
	private List<String> dbs; 

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.setContentView(R.layout.db_choose);
		//this.setContentView(R.layout.dbname_row);
    	
		dbs = BraveDictDbAdapter.listDictDbs();
		ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, dbs);
		setListAdapter(adapter);
		registerForContextMenu(getListView());		
	}


	@Override
	protected void onListItemClick(ListView l, View v, int position, long id) {
		super.onListItemClick(l, v, position, id);
		
		Intent i = new Intent();
		i.putExtra("DB_NAME", BraveDictDbAdapter.dictShortNameToFullName(dbs.get(position)));
		setResult(RESULT_OK, i);
		finish();
		
	}


	@Override
	public void onConfigurationChanged(Configuration newConfig) {
		super.onConfigurationChanged(newConfig);
	}
	
}
